home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 276-300 / disk_280 / graph / object.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  74 lines

  1. /*
  2.  *                 GRAPH, Version 1.00 - 4 August 1989
  3.  *
  4.  *            Copyright 1989, David Gay. All Rights Reserved.
  5.  *            This software is freely redistrubatable.
  6.  */
  7.  
  8. /* The object class. All the different objects are subclasses of it */
  9. #ifndef OBJECT_H
  10. #define OBJECT_H
  11.  
  12. #include <stdio.h>
  13. #include "list.h"
  14. #include "grph.h"
  15.  
  16. #define FNAMELEN 20 /* Length of object name */
  17.  
  18. struct object
  19. {
  20.     node node;
  21.     struct graph *g; /* Which graph this object is in (g->s.x,y contains curren
  22. t mouse pos)*/
  23.     char name [FNAMELEN]; /* Name (for functions only) "" otherwise */
  24.     int ok; /* For functions only: is it displayed */
  25.     int mx, my; /* Specify an (optional) displacement for the mouse pointer whe
  26. n this is selected */
  27.     struct Region *(*delete)    (struct object *this);
  28.     void           (*select)    (struct object *this); /* You have been selecte
  29. d */
  30.     struct Region *(*deselect)  (struct object *this); /* done. does the screen
  31.  need refreshing  ? */
  32.     int            (*down)      (struct object *this); /* User pressed button.
  33. Return TRUE if (x,y) is inside you */
  34.     void           (*move)      (struct object *this);
  35.     struct Region *(*up)        (struct object *this); /* Redraw necessary ? */
  36.      
  37.     int            (*edit)      (struct object *this, struct Region **ref); /*
  38. Returns true if graph changed */
  39.     void           (*draw)      (struct object *this, int allow_mes);
  40.     struct Region *(*improve)   (struct object *this);
  41.     char          *(*f2str)     (struct object *this, char *buf, int maxlen);
  42.     void           (*var_change)(struct object *this, char *name); /* Change in
  43.  variable "name" */
  44.     int            (*save)      (struct object *this, FILE *f);
  45.     int            (*inform)    (struct object *this); /* Inform of changes to
  46. g */
  47.     void           (*confirm)   (struct object *this, int ok); /* Confirm previ
  48. ous changes */
  49. };
  50.  
  51. /* A special object, used for selecting points on screen (cross hair mode) */
  52. /* The fields are public. Only new, down, move, up and deselect are implemented
  53.   */
  54. struct pos
  55. {
  56.     struct object o;
  57.     int cross : 1;
  58.     int rect : 1;
  59.     double x0, y0, x1, y1;
  60. };
  61.  
  62. struct pos *new_pos(struct graph *g);
  63.  
  64. /* A label on the graph */
  65. struct label *new_label(struct graph *g, double x, double y);
  66. struct label *load_label(struct graph *g, FILE *f);
  67.  
  68. /* A function (ie f(x), r(theta), etc */
  69. struct function *new_function(struct graph *g);
  70. struct function *load_function(struct graph *g, FILE *f);
  71.  
  72. #endif
  73.  
  74.